﻿//file: widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QStackedWidget>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QLabel>
#include <QGridLayout>
#include "background.h"
#include "charge.h"
#include "clock.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
/**
 * @brief The Widget class
 * 主窗口
 */
class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

protected:
    bool eventFilter(QObject *obj, QEvent *event) override;  //事件过滤函数

private:
    Ui::Widget *ui;
    QLabel label;                  //用于配合界面切换动画
    QStackedWidget stackWidget;    //用于存放管理界面
    Background *background;        //背景图界面
    Charge *charge;                //充电效果界面
    Clock *clock;                  //时钟界面
    //鼠标按下和释放时的坐标
    int press_x;
    int press_y;
    int release_x;
    int release_y;
    //界面切换动画。不知道为什么QPropertyAnimation只能用指针，不然关闭主窗口时会提示"pure virtual method called"
    QPropertyAnimation *animation1;
    QPropertyAnimation *animation2;
    QParallelAnimationGroup animationGroup;   //并行动画组
    QGridLayout *layout;             //界面布局
};
#endif // WIDGET_H
